(
    function(){
        const request={
            post(url,query={},callback,header={}){
                let xhr  = new XMLHttpRequest()
                //建立连接
                xhr.open("POST",url)
                //写请求头
                Object.keys(header).forEach(item=>{
                    xhr.setRequestHeader(item,header[item])
                })
                //发送
                xhr.send(JSON.stringify(query))
                //监听
                xhr.onreadystatechange=function(){
                    if(xhr.readyState=== 4){
                        callback(xhr.responseText)
                    }
                }
            }
        }
        window.request=request
    }
)()